package com.victor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.victor.dao.GroupDao;
import com.victor.dao.GroupTour_SignupDao;
import com.victor.entity.group.GroupCollection;
import com.victor.entity.group.GroupTour;
import com.victor.entity.group.GroupTour_Signup;
import com.victor.entity.group.Lycompany;
import com.victor.entity.group.LycompanyPhoto;
import com.victor.service.GroupService;

@Service
public class GroupServiceImpl implements GroupService {

	@Autowired
	private GroupDao dao;
	@Autowired
	private GroupTour_SignupDao tourDao;

	// 获取团游列表
	@Override
	public List<GroupTour> getGroupTour(String jqclassid, String starttime, String endtime, String search) {
		return dao.getGroupTour(jqclassid, starttime, endtime, search);
	}

	// 通过景区id查询开设景区团游的公司
	@Override
	public List<GroupTour> getLycompany(String jqid) {
		return dao.getLycompany(jqid);
	}

	// 通过旅游公司id查询旅游公司详情
	@Override
	public Lycompany getLycompanyXQ(String lycid) {
		return dao.getLycompanyXQ(lycid);
	}

	// 通过旅游公司id查询该公司都开设了哪些景区
	@Override
	public List<GroupTour> getGroupTourList(String lycid) {
		return dao.getGroupTourList(lycid);
	}

	// 获取旅游公司列表
	@Override
	public List<Lycompany> getLycompanyList() {
		return dao.getLycompanyList();
	}

	// 批量删除旅游公司
	@Override
	public boolean batchDeleteLycompany(int[] ids) {
		return dao.batchDeleteLycompany(ids) > 0 ? true : false;
	}

	// 新建旅游公司
	@Override
	public int addLycompany(Lycompany lycompany) {
		return dao.addLycompany(lycompany);
	}

	// 添加旅游公司照片
	@Override
	public int addLycompanyPhoto(LycompanyPhoto lycompanyPhoto) {
		return dao.addLycompanyPhoto(lycompanyPhoto);
	}

	@Override
	public PageInfo<GroupTour_Signup> selAllGround(int page, int row, String start, String end, String search,String tourid) {
		PageHelper.startPage(page, row);
		List<GroupTour_Signup> list = tourDao.selAllGroup(start,end,search,tourid);
		return new PageInfo<>(list, 5);
	}

	@Override
	public boolean delGroup(int[] ids) {
		return tourDao.deleteByPrimaryKey(ids);
	}

	@Override
	public List<GroupTour_Signup> selALL() {
		return tourDao.selAllGroup(null, null, null,null);
	}

	@Override
	public GroupTour_Signup selGroundById(Integer id) {
		return tourDao.selById(id);
	}

	@Override
	public PageInfo<GroupTour> selAllGroundTour(int page, int row, String search, String start, String end) {
		PageHelper.startPage(page, row);
		List<GroupTour> list = dao.selGroupTou(search,start,end);
		return new PageInfo<>(list, 5);
	}

	@Override
	public boolean delGroupTour(int[] ids) {
		return dao.delGroupTour(ids);
	}

	@Override
	public List<GroupTour> getGroupALL() {
		return dao.selAll();
	}

	@Override
	public GroupTour getGroupALLById(Integer id) {
		return dao.delGrouptouById(id);
	}

	@Override
	public PageInfo<GroupTour> selGroupByCity(String city,String classid,int page,int row) {
		PageHelper.startPage(page, row);
		List<GroupTour> list = dao.selGroupByCity(city,classid);
		return new PageInfo<>(list, 5);
	}

	@Override
	public boolean insertSign(GroupTour_Signup signup) {
		return tourDao.insertSelective(signup);
	}

	@Override
	public boolean updatePerson(String personnum, String grouptourid) {
		return dao.updatePerson(personnum,grouptourid);
	}

	@Override
	public GroupTour selByGroupId(Integer groupid) {
		return dao.selByGroupId(groupid);
	}

	@Override
	public GroupTour selByGroupIdAndUid(Integer groupid, String uid) {
		return dao.selByGroupIdAndUid(groupid,uid);
	}

	@Override
	public boolean insertCollction(GroupCollection controller) {
		return dao.insertGroupCollection(controller);
	}
}
